package servlet.servlet_yaobo;

import pojo.AssociationTable;
import pojo.Goods;
import pojo.RelationView;
import pojo.ShoppingCart;
import service.impl.ImpShoppingMemberService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

/**
 * 姚波
 * 用于获取商品的价格，图片路径，数量
 */
@WebServlet(value = "/commoditys1")
public class CommodityServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ImpShoppingMemberService imp=new ImpShoppingMemberService();
        ShoppingCart shoop=new ShoppingCart();
        List<RelationView> cartItems=new ArrayList<>();
        shoop=imp.sees(Integer.parseInt("1001"));
        cartItems=imp.shooup(shoop.getCartId());
        req.setAttribute("cartItems",cartItems);
       req.getRequestDispatcher("shopping.jsp").forward(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
